home *** CD-ROM | disk | FTP | other *** search
-
- INPUT subroutines replace BASIC's INKEY$ or INPUT commands, and add
- functions not available with BASIC alone.
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: ClearKey
- object file: clearkey.obj (getkey.obj)
-
- Removes all keypresses from the keyboard's "type ahead" buffer.
- Works with standard and enhanced keyboards.
-
- Example:
- CALL ClearKey
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Function: keycode% = DGetKey
- object file: dgetkey.obj
-
- Using DOS functions, DGetKey returns the ASCII character code of
- the first keypress waiting in the keyboard buffer. If the key code
- returned > 255, then the key pressed is an extended keycode (such as
- the function keys F1 - F10) and the ASCII code of the key is (code%
- AND 255). If no keypresses are waiting in the keyboard buffer,
- DGetKey waits until a key is pressed before it returns to BASIC.
- Unlike GetKey, below, input to DGeyKey may be redirected from the
- command line. DGeyKey does not support F11 or F12 function keys.
- DGetKey allows ^C to pass through as keycode% = 3 without causing your
- program to stop. ^<Break> works the same as ^C in compiled programs;
- in the QuickBASIC or QBX development enviornment, ^<break> causes
- suspension of program operation (as it normally does). See your BASIC
- manual for ASCII character codes.
-
- Example:
- REM $INCLUDE: 'qlib.bi'
- keycode% = DGetKey
- IF keycode% < 255 THEN PRINT CHR$(keycode%) ' prints key pressed
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Function: GPullDown(VARPTR(menu$(0)), choice0%, choice1%)
- object files: gpulldn.obj (q$menu.obj and several others)
- (for graphics modes)
-
- Function: PullDown(VARPTR(menu$(0)), choice0%, choice1%)
- object files: pulldown.obj (q$menu.obj and several others)
- (for text modes)
-
- Subroutine: MenuOption(optionnumber%, option% [option$ for option 6])
- object file: q$menu.obj
-
- Requires QuickBASIC or BC7 without /fs switch
- NOT for QBX development enviornment
-
- Pull-down menu system similar to the menus in the QuickBASIC
- development environment. You may specify initial main choice and
- initial submenu choice (choice0% and choice1%). PullDown returns to
- BASIC when either ESC or RETURN is pressed, and returns the menu choice
- in choice0% and choice1%. Use cursor keys, home/end, pgup/pgdown or
- mouse to move cursor. PullDown will also jump to a menu choice when an
- alphabetic key is pressed if that menu choice includes a capitalized
- letter, and the key pressed matches the capital letter ("Hotkey"
- feature). Menu choices are disabled if all lower case.
-
- PullDown saves the screen under the menu, and restores the
- previous screen when it exits.
-
- If choice1% (initial submenu choice) < 0, the main selections
- will be printed without submenus. You may move among the main
- headings with left & right arrow keys or with the mouse. Submenus
- are displayed when Enter or any mouse buttons are pressed, or when
- up or down arrows are pressed, or when the mouse pointer is moved up
- or down. Esc will erase the main headings and return to BASIC.
-
- MenuOption is used to specify colors. Options supported are:
-
- option 0 = normal text color
- option 1 = highlight color (menu choice)
- option 2 = menu box color
- option 3 = hotkey color
-
- If you do not specify colors, PullDown uses bright white text and
- menu box, reverse video menu choice and hotkey color.
-
- Other options are:
-
- option 4 = user-specified exit key code (see GetKey for keycodes)
- option 5 = exit when hotkey is pressed
- option 6 = user-specified string printed at right edge of screen
-
- Any menu option may be canceled by setting the option = 0.
-
- Example:
- see MENU.BAS example program
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Function: keycode% = GetKey
- object file: getkey.obj (asmflags.obj)
-
- Returns the ASCII character code of the first keypress waiting in
- the keyboard buffer. If the key code returned > 255, then the key
- pressed is an extended keycode (such as the function keys F1 - F10)
- and the ASCII code of the key is (code% AND 255). If no keypresses are
- waiting in the keyboard buffer, GetKey waits until a key is pressed
- before it returns to BASIC. GetKey supports F11 and F12 on 101-key
- keyboards if the PC's BIOS also supports 101-key keyboards (See GetKBD).
- See your BASIC manual for most ASCII character codes.
-
- ASCII character codes for F11 and F12 are not listed in some BASIC
- manuals:
- with SHIFT with CTRL with ALT
- F11 133 135 137 139
- F12 134 136 138 140
-
- Example:
- REM $INCLUDE: 'qlib.bi'
- keycode% = GetKey
- IF keycode% AND 256 THEN
- keycode% = keycode% AND 255
- IF keycode% = 138 THEN PRINT "CTRL+F12 was pressed"
- ELSE
- .
- .
- .
- END IF
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: HideMouse
- object file: mouse.obj (mousedat.obj)
-
- Makes the mouse cursor disappear. The mouse driver continues to
- track the mouse's motion and button status.
-
- Example:
- HideMouse
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: HideGMouse
- object file: gmouse.obj (mousedat.obj, $graph.obj)
-
- Makes the alternate graphics mouse cursor disappear. QLIB's
- alternate mouse driver continues to track the mouse's motion.
- See GMouse in GRAPHICS.DOC.
-
- Example:
- HideGMouse
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Function: k% = IsAlpha(keycode%)
- object file: isalpha.obj
-
- Function: k% = IsDigit(keycode%)
- Function: k% = IsLower(keycode%)
- Function: k% = IsUpper(keycode%)
- object file: isdlu.obj
-
- These function quickly determine if keycode% is an alphabetic
- character (A-Z, a-z: IsAlpha), a numeric digit (0-9: IsDigit), a
- lower-case alphabetic character (a-z: IsLower) or an upper-case
- alphabetic character (A-Z: IsUpper). k% = keycode% if keycode%
- meets the function's search criteria, or k% = 0 if keycode is not
- 0-9, A-Z, or a-z (depending on the function). Keycode% may be the
- output of LineEdit, GLineEdit or the GetKey or DGetKey functions.
-
- Example:
- REM $INCLUDE: 'qlib.bi'
- REM I want to input only lowercase a-z
-
- 10: k% = IsLower(GetKey)
- IF k% = 0 GOTO 10
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Function: k% = KeyFilter(s1$, s2$, keycode%)
- object file: keyfilt.obj
-
- KeyFilter compares keycode% to each character in the strings
- s1$ and s2$, and returns k% = 0 unless keycode% matches a character
- in the search strings. If keycode% is a normal character (i.e., not
- a function key), then s1$ is used. If keycode% is an extended keycode,
- (keycode% > 255) then s2$ is used. See example.
-
- Example:
- REM $INCLUDE: 'qlib.bi'
- REM I want to input only the letters a, c and g (upper or lower case)
- REM and I also want to watch for F10 (keycode% = 256 OR 68)
- s1$ = "aAcCgG"
- s2$ = CHR$(68)
- 10: k% = KeyFilter(s1$, s2$, keycode%)
- IF k% = 0 GOTO 10
-
- REM Note that KeyFilter may also be called using one of QLIB's input
- REM functions such as GetKey, DGetKey or KeyIfWaiting like this:
- REM 10: k% = KeyFilter(s1$, s2$, KeyIfWaiting)
- REM IF k% = 0 GOTO ...
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Function: keycode% = KeyIfWaiting
- object files: kifwait.obj (getkey.obj, asmflags.obj)
-
- Uses BIOS calls to determine whether a key is waiting in the keyboard
- buffer, returning the key to BASIC. If no key is waiting, KeyIfWaiting
- returns keycode% = 0. KeyIfWaiting supports F11 and F12 keys on 101-key
- keyboards if the PC's BIOS also supports these keyboards.
-
- Example:
- keycode% = KeyIfWaiting
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: KeyOrButton(buttons%, keycode%)
- object files: mouse.obj (getkey.obj)
-
- Returns first key pressed or mouse button pressed. If no key is waiting
- in the keyboard buffer and no mouse button is pressed, KeyOrButton waits
- until one of these events happens. If a key is waiting in the keyboard
- buffer before KeyOrButton is called, the key is returned to QB without
- checking mouse buttons. Buttons% = 0 if a key has been read, otherwise
- buttons% indicates which buttons are pressed. See GetKey for key codes,
- and see the example below for buttons% codes. More than one button may
- be pressed.
-
- Example:
- CALL KeyOrButton(buttons%, keycode%)
- msg$ = ""
- IF buttons% THEN
- IF buttons% AND 1 THEN msg$ = "left button pressed "
- IF buttons% AND 2 THEN msg$ = msg$ + "right button pressed "
- IF buttons% AND 4 THEN msg$ = msg$ + "center button pressed"
- PRINT msg$
- ELSE
- ' action for key pressed
- END IF
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Function: a% = KeyWaiting
- object file: getkey.obj (asmflags.obj)
-
- Uses BIOS calls to determine whether a key is waiting in the keyboard
- buffer, without reading the key. KeyWaiting supports F11 and F12 keys on
- 101-key keyboards if the PC's BIOS also supports these keyboards.
-
- Example:
- REM $INCLUDE: 'qlib.bi'
- IF KeyWaiting% THEN PRINT "A key has been pressed"
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: LineEdit(st$, row%, col%, attr%, options%, keycode%)
- Subroutine: StartEdit(startcol%)
- Function: LastEdit
- object files: lineedit.obj (crt.obj, q$qprn.obj, cursor.obj, getkey.obj)
-
- LineEdit displays st$ at (row%, col%) and provides many editing
- functions, returning the edited string to BASIC. The length of st$
- will not change during the editing process. Options are provided to
- restrict legal input or to provide additional information, depending on
- the bits set in options%. See LineEdit's Summary of Commands, below.
- See GetKey to interpret the keycode% returned by LineEdit.
- StartEdit may be used before calling LineEdit in order to begin or
- resume editing at a specified position in st$ (default position is
- 1, the left end of the string). LastEdit is used after LineEdit returns
- to BASIC, to determine the cursor position in st$ when control was
- returned to BASIC.
- LineEdit turns the cursor off when returning to BASIC. You may
- use BASIC's LOCATE command or QLIB's CursorON subroutine to restore
- the cursor. LineEdit works only in text mode. Use GLineEdit in graphics
- modes (See GLineEdit in GRAPHICS.DOC.). LineEdit will edit any string up
- to 32,767 bytes long. See also WindowEdit.
-
- Thanks to Thomas Cullins for his bug report on the BC7/QBX version of
- LineEdit.
-
- Summary of LineEdit commands:
-
- Enter, Esc = return string to BASIC
- Left arrow, Right arrow = move cursor
- Insert = toggle insert/overstrike modes
- Home = move cursor to start of line
- End = move cursor to end of text
- Delete = delete character at cursor and close up space
- Backspace = move cursor back one space, delete character, and close space
- Ctrl+End = clear from cursor to end of line
- Ctrl+Left, Ctrl+Right = move cursor one word
-
- LineEdit options and examples are on the next page.
-
-
- LineEdit options:
-
- 1 = Lower Case
- 2 = Upper Case
- 1 + 2 = Numerals only
- 1 + 2 + 4 = Numerals and numeric punctuation ($,.%-+*/)
- 8 = use BIOS to display string (default is DVM)
- 32 = Return to BASIC if cursor is past end of string
- 64 = Return to BASIC if normal key pressed
- 128 = Return to BASIC if extended key (F1 - F10, etc.) is pressed.
- NOTE: if this option is used and an extended key is pressed,
- keycode% returned as 256 + the ASCII code of the extended
- key. This may be used along with StartEdit and LastEdit
- to trap specified extended key presses. See examples.
- 256 = Return to calling program if ALT key is pressed. keycode%
- is returned = 256.
- -32768 = Use alternate reverse video cursor instead of the blinking
- hardware cursor. This option may cause "snow" on CGA monitors.
- The cursor position is indicated by a black character on a
- white background; in insert mode, either the character blinks
- or the background is high intensity, depending on the last call
- to SetBLINK (see VIDEO.DOC). To preserve compatability with
- future versions of LineEdit, do not use this option with
- option 8. This version of LineEdit ignores option -32768 if
- option 8 is used.
-
- Use BASIC's OR operator to combine options.
-
- Example 1:
- st$ = "This is the string to be edited "
- ' extra spaces allow for inserted characters
- row% = 5: col% = 10
- options% = 0 ' allow all characters, no fancy stuff
- CALL LineEdit(st$, row%, col%, attr%, options%, keycode%)
-
- Example 2:
- REM $INCLUDE: 'qlib.bi'
- st$ = "This is the string to be edited": row% = 5: col% = 10
- options% = 2 OR 128 ' All text input converted to upper case and
- ' return to calling program if extended key
- ' pressed.
- ' I want to trap F1, which returns the ASCII
- ' code a% = 59 (see your BASIC manual for
- ' extended key codes)
- 10 CALL LineEdit(st$, row%, col%, attr%, options%, keycode%)
- IF keycode% AND 256 THEN
- a% = keycode% AND 255
- IF a% = 59 THEN ... ' do F1 stuff
- ' else go back to LineEdit:
- CALL StartEdit(LastEdit) ' re-set cursor location
- GOTO 10 ' and go back to LineEdit
- END IF
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Function: keycode% = MaskEdit(mask$, row%, column%, attr%, options%)
- object file: maskedit.obj (getkey.obj, qprint.obj, cursor.obj)
-
- Permits a string with fixed fields and fixed delimiters to be
- edited. This can be used, for example, to input telephone numbers
- or ZIP codes, or other fixed-field data. MaskEdit will permit only
- the characters in the input string which are numbers, letters or
- space characters to be edited, skipping over field delimiters.
- MaskEdit will optionally limit input to numerals, or will force
- lower-case input, or upper-case input. MaskEdit returns to your
- BASIC program when either ESC or ENTER is pressed. MaskEdit options
- are:
-
- 1 = a-z forced to upper case
- 2 = A-Z forced to lower case
- 3 = numerals only allowed
-
- row% and column% are the location on the screen where you want
- the string to be printed, and attr% is the color attribute to be used.
- You may use the TAB key to jump from one field to the next, and
- shift+TAB jumps the cursor back to the previous field. You may also
- use the left, right, home and end keys to move the cursor.
-
- Example:
- REM $INCLUDE: 'qlib.bi'
- REM define the mask for entering telephone numbers
- REM I'm using CHR$(255) as a non-editable space character
- mask$ = "( )"+CHR$(255)+" - "
- phone$ = mask$ ' don't disturb mask$
- options% = 3
- keycode% = MaskEdit(phone$, row%, column%, attr%, options%)
- IF keycode% = 27 THEN ' ESC was pressed
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: MouseStatus(x%, y%, buttons%)
- object file: mstatus.obj (mousedat.obj)
-
- Returns the mouse button status and mouse position. Buttons% is
- a code which indicates which mouse buttons, if any, are pressed, and
- the PIXEL coordinates of the mouse cursor, even in text modes.
- Pixel coordinates start with (0,0) in the upper left corner.
- X-coordinates are horizontal and Y-coordinates are vertical (increasing
- from top of screen to bottom). See KeyOrButton to decode buttons%.
- To determine mouse cursor position in terms of text locations, see
- TMouseStatus.
-
- Example:
- CALL MouseStatus(x%, y%, buttons%)
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: ShowMouse
- object file: mouse.obj (mousedat.obj)
-
- ShowMouse makes the mouse cursor visible.
-
- Example:
- CALL ShowMouse
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: ShowGMouse
- object file: gmouse.obj (mousedat.obj, $graph.obj)
-
- ShowGMouse makes the alternate graphics mouse cursor visible.
- See GMouse in GRAPHICS.DOC.
-
- Example:
- CALL ShowGMouse
-
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: TMouseStatus(col%, row%, buttons%)
- object file: tmstatus.obj
-
- TMouseStatus is similar to MouseStatus, but returns the mouse cursor's
- position as (col%, row%) character coordinates instead of pixel
- coordinates. Note that most QLIB subroutines use column and row
- coordinates in reverse order (row%, col%) instead of TMouseStatus'
- (col%, row%). Buttons% is the mouse's button status. See KeyOrButton
- to decode button status.
-
- Example:
- CALL TMouseStatus(col%, row%, buttons%)
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Function: keycode% = VertList(VARPTR(a$(0)), row%, col%, choice%)
- object files: vlist.obj (q$menu.obj, getkey.obj, crt.obj, q$qprn.obj,
- several others)
-
- Requires QuickBASIC or BC7 without /fs switch
- NOT for QBX development enviornment
-
- Vertical list menu system; requires an array of varable-length strings,
- upper left corner coordinates (row%, col%) and starting position
- (choice%). VertList returns to QuickBASIC when Esc, Enter or an
- optional user-defined exit key is pressed, or when a mouse button is
- pressed. The keycode of the key pressed is returned as keycode% and
- the menu selection is returned as choice%. VertList uses all menu
- options except option 6 (user-specified prompt string). See MenuOption.
-
- Example:
- REM $INCLUDE: 'qlib.bi'
-
- DIM mainmenu$(9) ' 10 menu strings, 0-9; last string is NUL
- FOR I= 0 TO 9
- READ mainmenu$(I) ' strings are in a DATA statement
- ' end of menu string data marked with a NUL string
- NEXT I
- row% = 5: col% = 10: choice% = 0
- ' "light bar" positioned at mainmenu$(0)
- mm% = VARPTR(mainmenu$(0))
- keycode% = VertList(mm%, row%, col%, choice%)
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Subroutine: WindowEdit(st$, r0%, c0%, r1%, c1%, attr%, options%, keycode%)
- Subroutine: WStartEdit(start%)
- Function: WLastEdit
- object files: wedit.obj (qprintw.obj(crt.obj, q$qprn.obj, q$clrw.obj),
- cursor.obj, getkey.obj)
-
- Similar to LineEdit, WindowEdit edits the string st$ in a window on
- a text-mode screen and returns the result to BASIC. WindowEdit is still
- in the early stages of development; your comments and suggestions will
- influence my development of this subroutine.
-
- WindowEdit differs from LineEdit in that it includes word wrap and
- up/down cursor movement, and varies the length of the string st$, depending
- on text inserted or deleted. WindowEdit does not yet scroll to allow
- editing strings longer than the window can display (but this is on my
- list of enhancements). WindowEdit also does not yet use any options%.
- Note that you should use options% = 0 for compatability with future
- versions of WindowEdit. WStartEdit and WLastEdit are used with
- WindowEdit as StartEdit and LastEdit are used with LineEdit.
-
- Summary of WindowEdit commands:
-
- Enter, Esc = return string to BASIC
- Left, Right, Up, Down arrows = move cursor
- Insert = toggle insert/overstrike modes
- Home = move cursor to start of line
- End = move cursor to end of line
- Delete = delete character at cursor and close up space
- Backspace = move cursor back one space, delete character, and close space
- Ctrl+Left, Ctrl+Right = move cursor one word
-
-
-
-
- ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
-
- Function: YesNo
- object file: yesno.obj
-
- Waits for either "Y" or "N" to be pressed, then returns the ASCII
- character code of the key pressed. The character code returned will be
- the code for UPPER case "Y" or "N", regardless of whether the key pressed
- was upper or lower case.
-
- Example:
- REM $INCLUDE: 'QLIB.BI'
- PRINT "Are you sure? (Y/N)"
- REM ASC("Y") = 89, ASC("N") = 78
- IF YesNo = 89 THEN
- . ' instructions for Y response
- .
- .
- ELSE
- . ' instructions for N response
- .
- .
- END IF
-